cmake_minimum_required(VERSION 3.22 FATAL_ERROR)

project(add LANGUAGES CXX VERSION 0.1.0)

include(CPM)

# 打包工具
CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.10.0")

add_library(${PROJECT_NAME} STATIC add/add.h add/add.cpp)

target_include_directories(
  ${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
                         $<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
)

# ---- Create an installable target ----
packageProject(
  NAME ${PROJECT_NAME}
  VERSION ${PROJECT_VERSION}
  NAMESPACE ${PROJECT_NAME}
  BINARY_DIR ${PROJECT_BINARY_DIR}
  INCLUDE_DIR ${PROJECT_SOURCE_DIR}/add
  INCLUDE_HEADER_PATTERN "*.h"
  INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}/include
  VERSION_HEADER "version.h"
  COMPATIBILITY SameMajorVersion
  DEPENDENCIES ""
)